import React from 'react'


import MenuCommon from './menuCommon'


export default class SubMenuPerfect extends React.Component{

    componentWillMount(){
        window.portalTs.element.menuPerfect.openSubMenuPerfect = 1
        window.portalTs.element.menuPerfect.setSubMenuPerfectData = this.setSubMenuPerfectData
        if(window.portalTs.element.menuPerfect.reflush){
            window.portalTs.element.menuPerfect.reflush()
        }

    }

    componentWillUnmount(){
        window.portalTs.element.menuPerfect.openSubMenuPerfect = 0
        if(window.portalTs.element.menuPerfect.reflush){
            window.portalTs.element.menuPerfect.reflush()
        }
    }

    state ={
        parentId:-1,
        subMenuData: [],
    }

    setSubMenuPerfectData = (id,subMenuData)=>{
        this.setState({parentId:id,subMenuData})
    }

    render(){
        const {parentId,subMenuData} = this.state
        return (
            <MenuCommon ecId={`${this && this.props && this.props.ecId || ''}_MenuCommon@76usj5`} {...this.props} hideTab={true} subMenuData={subMenuData} parentId={parentId}></MenuCommon>
        )
    }
}